#include <cstdio>

using namespace std;

typedef long long ll;

const int maxn=300, maxm=300;

bool map[maxn+1][maxm+1];
int col[maxn+1][maxm+1];

void dfs(int x, int y, int x1, int y1, int x2, int y2, int typ, int c) {
    const static int dir[4][2]={{-1, 0}, {0, -1}, {1, 0}, {0, 1}};
    col[x][y] = c;
    for (int i=0; i<4; i++) {
        int nx=x+dir[i][0], ny=y+dir[i][1];
        if (nx>=x1 && ny>=y1 && nx<=x2 && ny<=y2 && map[nx][ny]==typ && col[nx][ny]!=c) {
            dfs(nx, ny, x1, y1, x2, y2, typ, c);
        }
    }
}

int solve(int x1, int y1, int x2, int y2) {
    static int ver;
    int black=0, white=0;
    for (int i=x1; i<=x2; i++) {
        for (int j=y1; j<=y2; j++) {
            if (map[i][j]) {
                if (!black) {
                    black=++ver;
                    dfs(i, j, x1, y1, x2, y2, 1, black);
                } else if (col[i][j]!=black) return 0;
            }
        }
    }
    if (!black) return 0;

    white = ++ver;
    for (int i=x1; i<=x2; i++) {
        if (!map[i][y1] && col[i][y1]!=white) dfs(i, y1, x1, y1, x2, y2, 0, white);
        if (!map[i][y2] && col[i][y2]!=white) dfs(i, y2, x1, y1, x2, y2, 0, white);
    }
    for (int i=y1; i<=y2; i++) {
        if (!map[x1][i] && col[x1][i]!=white) dfs(x1, i, x1, y1, x2, y2, 0, white);
        if (!map[x2][i] && col[x2][i]!=white) dfs(x2, i, x1, y1, x2, y2, 0, white);
    }
    for (int i=x1; i<=x2; i++) {
        for (int j=y1; j<=y2; j++) {
            if (!map[i][j] && col[i][j]!=white) return 0;
        }
    }
    return 1;
}

int main() {
    freopen("village.in", "r", stdin);
    freopen("checker.out", "w", stdout);

    int n, m;
    scanf("%d %d", &n, &m);
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            int t;
            scanf("%1d", &t);
            map[i][j] = t;
        }
    }

    ll ret=0;
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            for (int x=i; x<=n; x++) {
                for (int y=j; y<=m; y++) {
                    ret += solve(i, j, x, y);
                }
            }
        }
    }
    printf("%lld\n", ret);

    fclose(stdin);
    fclose(stdout);
    return 0;
}
